//
//  ViewController.m
//  UIViewTransformPoint
//
//  Created by codew on 4/30/21.
//

#import "ViewController.h"

/* 登录成功通知 **/
#define kNotificationLoginSuccess @"kNotificationLoginSuccess"

@interface ViewController ()

@property (nonatomic, strong) UIView * viewTest;


@property (nonatomic, weak) IBOutlet UIImageView *hourHand;
@property (nonatomic, weak) IBOutlet UIImageView *minuteHand;
@property (nonatomic, weak) IBOutlet UIImageView *secondHand;
@property (nonatomic, weak) NSTimer *timer;

@property (nonatomic, strong) id observer;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(vueDidFinishLaunchingWithOptions)
                                                 name:kNotificationLoginSuccess
                                               object:nil];
//
    
//    self.observer = [[NSNotificationCenter defaultCenter] addObserverForName:kNotificationLoginSuccess
//                                                      object:nil
//                                                       queue:[NSOperationQueue new]
//                                                  usingBlock:^(NSNotification * _Nonnull note) {
//
//        NSLog(@"%s, %@", __func__, [NSThread currentThread]);
//    }];
}



- (void)vueDidFinishLaunchingWithOptions
{
    NSLog(@"%s, %@", __func__, [NSThread currentThread]);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    NSLog(@"%s", __func__);
    
    
    dispatch_async(dispatch_get_main_queue(), ^{

        //        // 通知登录成功
        [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationLoginSuccess
                                                            object:nil];
    });
////
    
    
//    dispatch_async(dispatch_get_global_queue(0, 0), ^{
//
//        //        // 通知登录成功
//        [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationLoginSuccess
//                                                            object:nil];
//
//    });
}

- (void)dealloc {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self.observer];
}


@end



//
//// 测试任意点旋转
//@implementation ViewController (cc)
//
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//
//
//    _viewTest = [[UIView alloc] initWithFrame:CGRectMake(140, 240, 150, 60)];
//    _viewTest.backgroundColor = [UIColor redColor];
//    [self.view addSubview:_viewTest];
//
//
//    self.viewTest.layer.anchorPoint = CGPointMake(0, 0);
//
//
////    UIImage * image = [UIImage imageNamed:@"index_more"];
////
////    self.viewTest.layer.contents = (id)image.CGImage;
////    self.viewTest.layer.contentsGravity = kCAGravityResizeAspect;
//
//}
//
//
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    NSLog(@"%s", __func__);
//
////    static BOOL result= NO;
////
////    if (!result) {
////
////        self.viewTest.layer.anchorPoint = CGPointMake(0, 0);
////
////    } else {
////
////        self.viewTest.layer.anchorPoint = CGPointMake(0.5, 0.5);
////
////    }
////
////    result = !result;
//
//
//    static int second = 10;
//
//    CGFloat secsAngle = (second / 60.0) * M_PI * 2.0;
//    self.viewTest.transform = CGAffineTransformMakeRotation(secsAngle);
//
//
//    second += 10;
//
//}
//
////
////- (void)viewDidLoad
////{
////    [super viewDidLoad];
////
////    self.secondHand.layer.anchorPoint = CGPointMake(0.5f, 0.9f);
////        self.minuteHand.layer.anchorPoint = CGPointMake(0.5f, 0.9f);
////        self.hourHand.layer.anchorPoint = CGPointMake(0.5f, 0.9f);
////
////    //start timer
////    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(tick) userInfo:nil repeats:YES];
////    //set initial hand positions
////    [self tick];
////}
////
////
////- (void)tick
////{
////    //convert time to hours, minutes and seconds
////    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
////    NSUInteger units = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
////    NSDateComponents *components = [calendar components:units fromDate:[NSDate date]];
////    CGFloat hoursAngle = (components.hour / 12.0) * M_PI * 2.0;
////    //calculate hour hand angle //calculate minute hand angle
////    CGFloat minsAngle = (components.minute / 60.0) * M_PI * 2.0;
////    //calculate second hand angle
////    CGFloat secsAngle = (components.second / 60.0) * M_PI * 2.0;
////    //rotate hands
////    self.hourHand.transform = CGAffineTransformMakeRotation(hoursAngle);
////    self.minuteHand.transform = CGAffineTransformMakeRotation(minsAngle);
////    self.secondHand.transform = CGAffineTransformMakeRotation(secsAngle);
////}
//
//
//
//
//@end

